<!-- "Save Script" place holder -->

<!--<input type="button" value="thanh" id="thanh"/>
<a class="export1" id="btnAll1"> Save Script placeholder</a>-->

<script language="javascript" id="thisScript">

//
//$(document).ready (function () { 
//   $('#thanh').click(function(){
//
//        $.ajax({
//                type: 'POST',
//                //url: 'http://salarycaculation.com/mod_payroll/test',
//                url: 'http://salarycaculation.com/employeesalary/exports',
//                //data: 'your post data',
//                success: function(response) {
//                    alert(response);
//                    var response = $.evalJSON(r);                    
//                    if(response.message) {
//                       //do some animation
//                       alert(response);
//                    }
//                }
//            });
//    });
//});


//function executeExports(){
//                $.ajax({
//                type: 'POST',
//                //url: 'http://salarycaculation.com/mod_payroll/test',
//                url: 'http://salarycaculation.com/employeesalary/exports',
//                //data: 'your post data',
//                success: function(response) {
//                    alert(response);
//                    var response = $.parseJSON(response); 
//                    //alert(response.url);
//                     return response.url
//                    if(response.url) {
//                       //do some animation
//                       //alert(response.url);
//                       return response.url
//                    }
//                }
//                
//            });
//            
//}

	
// -------------------------------------------------------------------	
//  Save the <script> in this page
// -------------------------------------------------------------------
// Saves a file based on a URL to the local computer.		

//opensave.make({                                 
//                                width: 		50,
//				height: 	20,
//				//filename: 	"Page Script.js", 
//                                url: 		"http://salarycaculation.com/exports/excel/company/2014-07-02-1019.xls",
//				label: 		"<?php echo $this->lang->line('MC005'); ?>",
//				buttonDiv: 	"btnAll1", 
//				dataID: 	"thisScript"
//				}
//			);
//
//
</script>

<div class="listorvertime">
    <h2><?php echo $this->lang->line('esl__title_employeesalarylist'); ?></h2>
    <div class="clr"></div>
     <form action="" method="post">
    <table class="tblsearch"  style="float: left;margin-right: 25px">
        <tr>
            <td><?php echo $this->lang->line('esl__name'); ?></td>
            <td><?php echo form_input('txtEmployeeName',  $employeeName); ?><span class="error"><?php echo form_error('txtEmployeeName'); ?></span></td>
            <input type="hidden" name="btnSubmit" value="true"/>
            <td>
                <input type="submit" name="btnSubmit" value="<?php echo $this->lang->line('MC004'); ?>">
               <!-- <input type="button" name="btnreset" value="Reset">-->
            </td>
        </tr>
    </table>
    </form>
    <table class="tblsearch exp">
        <tr>
            <td><?php echo $this->lang->line('esl__totalsalary'); ?></td>
            <td><?php echo number_format($totalSalary[0]['NetSalary'],0, ',', '.') ?> <?php echo $this->lang->line('MC006'); ?></td>
            <td>
                
                <?php 
                if($messsageError==""){
                    if($employeeName==""){ ?>
                       <a id="btnAll1" class="export1" href="/employeesalary/exports"><?php echo $this->lang->line('MC005'); ?></a>
                    <?php }else{ ?>
                            <a id="btnAll2" class="export1" href="/employeesalary/exports/<?php echo $employeeName ?>"><?php echo $this->lang->line('MC005'); ?></a>
                    <?php } 
                     }else{ ?>                            
                            <a class="export1" style="opacity: 0.5;" href="javascript:void(0)"><?php echo $this->lang->line('MC005'); ?></a>
                    <?php     
                     }
                    ?>
            </td>
        </tr>
    </table>
    
    <a href="index.php"></a>
    <div class="clr"><?php       
       //echo "<label for='disabledSelect' style='color:red;'>".$messsageError."</label>";
    ?></div>
    <div class="clr"></div>
    <table class="tbllist" style="margin-bottom: 0px;" border="1">
        <tr>
            <th><?php echo $this->lang->line('esl__no'); ?></th>
            <th><?php echo $this->lang->line('esl__employeeid'); ?></th>
            <th><?php echo $this->lang->line('esl__fullname'); ?></th>
            <th><?php echo $this->lang->line('esl__month'); ?></th>
            <th><?php echo $this->lang->line('esl__workhours'); ?></th>
            <th><?php echo $this->lang->line('esl__employeesalary'); ?></th>
            <th><?php echo $this->lang->line('esl__action'); ?></th>
        </tr> 
        <?php $count = $page + 1; ?>
        <?php
            
            foreach ($data as $row){
        ?>
        <tr>
            <td><?php echo $count++; ?></td>
            <td><?php echo $row['EmployeeId']; ?></td>
            <td><?php echo subString(dQuotes($row['EmployeeName']),30,null); ?></td>
            <td><?php echo $row['Month']; ?>/<?php echo $row['Year']; ?></td>
            <td><?php echo number_format($row['ActualAttendant'],0, ',', ','); ?></td>
            <td id="salary"><?php echo number_format($row['NetSalary'],0, ',', ','); ?> <?php echo $this->lang->line('MC006'); ?></td>
            <td>
                <a  id="<?php echo $row['EmployeeId'].'/'.$row['Month'].'/'.$row['Year']?>" class="export2" href="javascript:void(0)" ><img style="margin-bottom: -2px;" src="<?php echo base_url();?>public/sites/images/export.png" title="<?php echo $this->lang->line('MC005'); ?>"></a>
            </td>
        </tr>
        <?php 
             
            } ?>       
        
    </table>
    <label for='disabledSelect' > <?php echo $messsageError; ?></label>
    <div class="clr"></div>
    <?php 
        echo "<br /><div class='h_pagination' >" .$this->pagination->create_links() ."</div>";
    ?>  
    <style>
        .h_pagination strong{float:left;}
    </style>
   
</div>
<!--<div id="dialog-message" title="<?php echo $this->lang->line('esl__titledialog'); ?>" style="display:none;">  
  <p>
    <?php echo $this->lang->line('esl__msgdialog'); ?></b>.
  </p>
</div>
 -->

 
  <script>
  $(function() {
//     $( "#btnAll1" ).click(function() {
//        $( "#dialog-message" ).dialog({
//          modal: true,
//          buttons: {
//            Ok: function() {
//              $( this ).dialog( "close" );
//              window.location.href='/employeesalary/exports';
//            }
//          }
//        });
//    });
//    //
//    $( "#btnAll2" ).click(function() {
//        $( "#dialog-message" ).dialog({
//          modal: true,
//          buttons: {
//            Ok: function() {
//              $( this ).dialog( "close" );
//              window.location.href='/employeesalary/exports/<?php echo $employeeName ?>';
//            }
//          }
//        });
//    });
//    //
//     $( ".export2" ).click(function() {      
//      var id=$(this).attr('id');     
//        $( "#dialog-message" ).dialog({
//          modal: true,
//          buttons: {
//            Ok: function() {               
//              $( this ).dialog( "close" );
//              window.location.href='/employeesalary/export/'+id;
//            }
//          }
//        });
//    });

     $( ".export2" ).click(function() {      
      var id=$(this).attr('id');     
              window.location.href='/employeesalary/export/'+id;
    });
  });
  </script>
<script type="text/javascript">
    $(document).ready(function() {
        $('.h_pagination a').click(function(e) {           
            e.preventDefault();
            var url = $(this).attr('href');             
            if (url != 'javascript:void(0)') {
                $('form').attr('action', url);
                $('form').submit();
            }
        });
    });
</script>